using B.S.Data.ERP.API.Applications.DingDanCommands;
using ERP.Domain;
using ERP.infratrctrue;
using ERP.Requst;
using MediatR;
using B.S.Data.ERP.API.Applications.DingDanCommands;

namespace B.S.Data.ERP.API.Applications.DingDanHandlers
{
    public class DeleteDingDanCommandHandler : IRequestHandler<DeleteDingDanCommand, APIRequust<int>>
    {
        private readonly IBaseRepository<DingDan> _dingDanRepository;

     
        public DeleteDingDanCommandHandler(IBaseRepository<DingDan> dingDanRepository)
        {
            _dingDanRepository = dingDanRepository;
        }

        public async Task<APIRequust<int>> Handle(DeleteDingDanCommand request, CancellationToken cancellationToken)
        {

            var su = _dingDanRepository.GetAll().FirstOrDefault(x => x.Id == request.Id);
            su.IsDele = true;
            return new APIRequust<int>
            {
                Code = RequstCode.成功,
                Msg = RequstCode.成功.ToString()
            };

        }
    }
}